#! /usr/bin/bash
dhcpcd
systemctl enable dhcpcd

#8.Timezone Setting
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

#9.Hardware Time Setting
hwclock --systohc --localtime
echo "时间已完成设置"

#10.Hostname Setting
read -p "输入你的用户名:" HOSTNAME
echo ${HOSTNAME} > /etc/hostname

#11.Language Setting
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf

#12 Passwd Setting
echo "输入你的用户密码:"
passwd

#13.Initramfs
sed -i '/^HOOKS/cHOOKS=(base udev block keyboard autodetect modconf filesystems fsck)' /etc/mkinitcpio.conf
mkinitcpio -P
echo "创建新的初始化完成"

#14.Install Grub
echo "安装Grub"
lsblk
read -p "选择您的U盘:" DISK
pacman -S grub efibootmgr
grub-install --target=i386-pc /dev/${DISK}
grub-install --target=x86_64-efi --efi-directory=/boot/efi --removable --recheck
grub-mkconfig -o /boot/grub/grub.cfg
echo "Grub安装完成"

read -p "是否安装KDE图形桌面？输入大写Y安装:" CX

if [[ ${CX} = Y ]]; then

  echo 安装过程可能需要30分钟左右，请耐心等待 && sudo pacman -S plasma xorg xorg-server kde-applications alsa-utils pulseaudio pulseaudio-alsa -y 
else
  exit
fi
echo 安装完成，输入法和中文语言请自行网上百度安装

read -p "您是否要关机？输入Y关机:" CX

if [[ ${CX} = Y ]]; then
  poweroff
else
  exit
fi
